<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</meta>
<title>F.search</title>
<link type="text/css" rel="stylesheet" href="../css/admin.css" />
<link type="text/css" rel="stylesheet" href="../css/item_show.css" />
<script type="text/javascript" src="../../1st.js"></script>
<script type="text/javascript" src="../../1st.highlight.js"></script>
</head>
<body id="split">
<div id="content">
	<div rel="F.param">
		<h2><span>返回值:</span>F.search</h2>
					<h3>概述 : 快速查找（二分法）</h3>
						
			<div class="desc">
				<div class="longdesc"><pre>查找指定值的原始的位置

原型写法：arrayObj.search(num) 或  arrayObj.search(eqExp)</pre></div>
			</div>
							<h3>语法1：F.search(arrayObj, num)</h3>
							<div>描述：查找简单数组的值</div>
						<table class="args">
				<!--caption>参数列表：(2)</caption-->
				<tr><th>参数名称</th><th>类型</th><th>描述</th></tr>
									<tr><td><strong>arrayObj</strong></td><td>Array</td><td>目标数组</td></tr>
									<tr><td><strong>num</strong></td><td>Number</td><td>元素值</td></tr>
								<tr><td colspan="3">&nbsp;</td></tr>
				<tr><td>返回值</td><td>Number</td><td>找不到返回-1</td></tr>
			</table>
					<h3>语法2：F.search(arrayObj, eqExp)</h3>
							<div>描述：查找二维数组的值</div>
						<table class="args">
				<!--caption>参数列表：(2)</caption-->
				<tr><th>参数名称</th><th>类型</th><th>描述</th></tr>
									<tr><td><strong>arrayObj</strong></td><td>Array</td><td>目标数组</td></tr>
									<tr><td><strong>eqExp</strong></td><td>String</td><td>key=value表达式</td></tr>
								<tr><td colspan="3">&nbsp;</td></tr>
				<tr><td>返回值</td><td>Number</td><td>找不到返回-1</td></tr>
			</table>
				<div class="example">
			<h3>示例 : </h3>
						
									
				<h5 xmlns="">JS代码:</h5>
				<pre xmlns=""><code id="jsbox"></code></pre>
										
				<h5 xmlns="">结果:</h5>
				<pre xmlns=""><code id="resultbox"></code><code></code></pre>
					</div>
		<div style="text-align:right">
			
					
				<button onclick="window.open('../codepages/103.html');">运行代码</button>
						
		</div><br/>	
		<div>
			<h3>同类参考 :</h3>
			<div>
							<span><a href='111.html'>F.map</a></span>&#12288;|&#12288;							<span><a href='142.html'>F.filter</a></span>&#12288;|&#12288;							<span><a href='105.html'>F.eq</a></span>&#12288;|&#12288;							<span><a href='69.html'>F.index</a></span>&#12288;|&#12288;							<span><a href='135.html'>F.shuffle</a></span>&#12288;|&#12288;							<span><a href='39.html'>F.unique</a></span>&#12288;|&#12288;							<span><a href='12.html'>F.swap</a></span>&#12288;|&#12288;							<span><a href='191.html'>F.sortby</a></span>&#12288;|&#12288;							<span><a href='159.html'>F.range</a></span>&#12288;|&#12288;							<span><a href='194.html'>F.up</a></span>						</div>
		</div>
	</div>
</div><br />

<textarea id="css" style="display:none;"></textarea>
<textarea id="html" style="display:none;"></textarea>
<textarea id="js" style="display:none;">alert([1,3,4,5,6,8,9,24].search(9));

var result = [
	{name:"classA", score:30},
	{name:"classB", score:40},
	{name:"classC", score:50},
	{name:"classD", score:60},
	{name:"classE", score:70},
	{name:"classF", score:80},
	{name:"classG", score:90}
];

var idx = result.search("v.score=55");
F.alert(idx)>-1 && alert(result[idx].name);
idx = result.search("v.score=70");
F.alert(idx)>-1 && alert(result[idx].name);
idx = result.search("75<=v.score<85");
F.alert(idx)>-1 && alert(result[idx].name);</textarea>
<textarea id="result" style="display:none;">6
-1
4
"classE"
5
"classF"</textarea>


<script type="text/javascript">
var css = F('css').val();
var html = F('html').val();		
var js = F('js').val();
var result = F('result').val();
css && F('cssbox').highlight(css, "css");
html && F('htmlbox').highlight(html, "html");
js && F('jsbox').highlight(js, "js");
result && F('resultbox').highlight(result,"js");
</script>

</body>
</html>